class ListNode {
    public int val;
    public ListNode next;
    public ListNode(int val) {
        this.val = val;
    }
    public ListNode head;
}
public class Solution{
    public ListNode deleteDuplication(ListNode pHead){
        ListNode cur = pHead;
        ListNode newHead = new ListNode(-1);
        ListNode tmpHead = newHead;
        //遍历链表的每个节点
        while(cur != null){
            if(cur.next != null && cur.val == cur.next.val){
                //一直让cur走到不重复的节点，然后把这个节点加入到不重复的链表当中
                while(cur.next != null && cur.val == cur.next.val){
                    cur = cur.next;
                }
                cur = cur.next;
            }else{
                tmpHead.next = cur;
                tmpHead = tmpHead.next;
                cur = cur.next;
            }
        }
        tmpHead.next = null;
        return newHead.next;
    }
}